package com.ggh.jinjilive.ui.mine.zhubo;

import android.os.Bundle;

import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.blankj.utilcode.util.BarUtils;
import com.ggh.jinjilive.BaseApplication;
import com.ggh.jinjilive.R;
import com.ggh.jinjilive.databinding.ActivityZhuboEarningsBinding;
import com.ggh.jinjilive.mobile.mine.zhubo.ZhuBoEarningsMobile;
import com.ggh.jinjilive.ui.BaseActivity;
import com.ggh.jinjilive.ui.mine.MineViewModel;
import com.ggh.jinjilive.utils.ARouterUtils;
import com.gyf.immersionbar.ImmersionBar;


/**
 * 主播收益
 */

@Route(path = ARouterUtils.ZhuBoEarningsActivity)
public class ZhuBoEarningsActivity extends BaseActivity<ActivityZhuboEarningsBinding> {
    private ZhuBoViewModel zhuBoViewModel;


    @Override
    public void initCreate() {
        super.initCreate();
        ImmersionBar.with(this).keyboardEnable(true).init();
        BaseApplication.getInstance().getAppComponent().doInjectionMain(this);
        zhuBoViewModel = new ViewModelProvider(this,viewModelFactory).get(ZhuBoViewModel.class);

    }

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_zhubo_earnings;
    }


    @Override
    public void initView() {
        super.initView();
        setWhiteActionBarStyle("主播收益",true,true);
        //获取状态栏高度
        binding.llSpacing.setPadding(0, BarUtils.getStatusBarHeight(),0,0);
    }

    @Override
    public void initData() {
        super.initData();
        //主播收益
        zhuBoViewModel.AnchorAnchorIncome();
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();
        //主播收益
        zhuBoViewModel.mZhuBoEarningsMobile.observe(this, new Observer<ZhuBoEarningsMobile>() {
            @Override
            public void onChanged(ZhuBoEarningsMobile zhuBoEarningsMobile) {
                if(null != zhuBoEarningsMobile){
                    binding.sentDiamondText.setText(String.valueOf(zhuBoEarningsMobile.getPoint_wallet()));
                    binding.unsentDiamondText.setText(String.valueOf(zhuBoEarningsMobile.getApply_point_wallet()));
                    binding.tvLive.setText(zhuBoEarningsMobile.getLive() +"元");
                    binding.chatProfitText.setText(zhuBoEarningsMobile.getVoice() + "元");
                    binding.familyProfitText.setText(zhuBoEarningsMobile.getFamily() + "元");
                    binding.advertisementProfitText.setText(zhuBoEarningsMobile.getPromotion() + "元");
                    binding.weeklyProfitText.setText(zhuBoEarningsMobile.getWeek() + "元");
                    binding.monthlyProfitText.setText(zhuBoEarningsMobile.getMonth() + "元");
                }
            }
        });
    }
}
